package no.ntnu.fp.gui.dialog;

import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * @author H�kon Heggedal
 * Nederste bit p� dialogvinduet
 * 
 * kan sette tekst p� submitknapp i constructor, eller etter hvert
 * 
 */
@SuppressWarnings("serial")
public class SaveOrCancel extends JPanel {
	
	private JButton submitButton;
	private JButton cancelButton;

	/**
	 * Create the panel.
	 */
	public SaveOrCancel() {
		setPreferredSize(new Dimension(350, 55));
		
		submitButton = new JButton();
		submitButton.setBounds(200, 11, 140, 33);
		submitButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				// TODO
			}
		});
		setLayout(null);
		submitButton.setFont(new Font("Tahoma", Font.PLAIN, 15));
		add(submitButton);
		
		cancelButton = new JButton("Avbryt");
		cancelButton.setBounds(100, 11, 90, 33);
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				// TODO
			}
		});
		cancelButton.setFont(new Font("Tahoma", Font.PLAIN, 15));
		add(cancelButton);
		
	}
	
	/**
	 * @param text new text on submit button
	 */
	public void setSubmitText(String text){
		submitButton.setText(text);
		submitButton.repaint();
	}
	public void setCancelText(String text){
		cancelButton.setText(text);
		cancelButton.repaint();
	}
	
	public void addButtonListeners(ActionListener acceptListener,
									ActionListener cancelListener) {
		this.submitButton.addActionListener(acceptListener);
		this.cancelButton.addActionListener(cancelListener);
	}
}
